var FontSuck = function(imageid,visiblemosaic){
  image = document.getElementById(imageid);
  mosaic = Mosaic("hiddencanvas");
  imageloader = ImageLoader(image);
  rawimage = MemTile(mosaic,0,0,image.width,image.height);
  imageloader.sprayImage(rawimage);
  var blobs = get_blobs(rawimage)
  var charsize = median_size(blobs.rects);
  var numoftiles = 0;
  var tiles = []
  var memtilemanager = TileManager(visiblemosaic,MemTile)
  for(var i in blobs.rects){
    if(blobs.rects[i].xS>charsize[0] || blobs.rects[i].yS>charsize[1])
      continue;
    var character = memtilemanager.makeTile((charsize[0]+1)*Number(numoftiles),10,charsize[0],charsize[1]); 
    rawimage.sprayImage(character,blobs.rects[i].xD,blobs.rects[i].yD,blobs.rects[i].xS,blobs.rects[i].yS);
    numoftiles +=1
  }
  
  return{
    click: function(xpos,ypos){
      return;
    },
    keypress: function(key){

    },
    tiles:memtilemanager
  }

}


var fontsucktest = function(){
  var mosaic = Mosaic("canvases",{bg:{r:255,g:255,b:255,a:255},tileSize:9});
  var fsuck = FontSuck("font2",mosaic);
  var s = Selector(mosaic);
  //s._drawSelect = _hotpink_drawSelect
  s.select(fsuck.tiles.rectsmanager.rects[1])
  

}
